﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccess
{
    public class DepotDataAccess
    {
        public static void InsertNewDepot(Model.Depot depot)
        {
            SSDDEntities.Instance.DiscardChanges();
            SSDDEntities.Instance.Depots.Add(depot);
            SSDDEntities.Instance.SaveChanges();
        }

        public static void ModifyNewDepot(Model.Depot depot)
        {
            SSDDEntities.Instance.DiscardChanges();
            var q = (from s in SSDDEntities.Instance.Depots
                     where s.DepotId == depot.DepotId
                     select s).First();
            q.ProductId = depot.ProductId;
            q.PricePurchaseActual = depot.PricePurchaseActual;
            q.DepotQuantity = depot.DepotQuantity;
            SSDDEntities.Instance.SaveChanges();

        }

        public static List<Model.Depot> GetDepots
        {
            
            get {SSDDEntities.Instance.DiscardChanges(); return SSDDEntities.Instance.Depots.ToList(); }
        }
    }
}
